#include <util\AutomaticInstallation.au3>


Global $InstallProgramPath = "C:\Program Files\AutoIt3\AutoIt3.exe"
Global $InstallFolder      = "C:\Program Files\AutoIt3"
	
Global $SetupFile = "autoit-v3-setup.exe"
Global $UninstallPath = "C:\Program Files\AutoIt3\Uninstall.exe"
Main($InstallProgramPath, $InstallFolder, $SetupFile, $UninstallPath)

Func InstallImpl($SetupPath) 
	Dim $Title = ""
	
	RunSetupFile($SetupPath)
	
	$Title = "AutoIt v3.3.6.1 Setup"
	WinWaitActive($Title)
	Send("!N")
	Sleep($SleepDelay)
	
	
	WinWaitActive($Title)
	Send("!A")
	Sleep($SleepDelay)
	
	; choose install path
	WinWaitActive($Title)
	Send("{DOWN}")
	Send("!N")
    Sleep($SleepDelay)	
	
	; choose shortcut path
	WinWaitActive($Title)
	Send("!N")
	Sleep($SleepDelay)
	
	WinWaitActive($Title)
	Send("!I")
		
	Dim $FinishButtonText = "&Finish"
	WinWaitActive($Title, $FinishButtonText)
	Send("{SPACE}")
	Send("!F")
	
	WinWaitClose($Title)

	Return True
EndFunc

Func UninstallImpl($UninstallPath)
	Dim $Title = ""
	Run($UninstallPath)
	
	$Title = "AutoIt v3.3.6.1 Uninstall"
	; Confirms unstall process
	WinWaitActive($title)
	Send("!U")
	Sleep($SleepDelay)

	Dim $FinishMsg = "Uninstallation Complete"
	WinWaitActive($Title, $FinishMsg)
	Send("!C")

	Return True
EndFunc




